home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / qprt_jf.com / QPDEMO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-07-04  |  2.3 KB  |  102 lines

  1. /*
  2.  * QPDEMO.C - qprintf and qputch demo - Jeff R. Fontanesi, 7/3/89
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <conio.h>
  7. #include "qprintf.h"
  8.  
  9. void qpdemo(void);               /* Demo routine using qprintf and qputch */
  10. void cpdemo(void);               /* Demo routine using cprintf and putch */
  11.  
  12.  
  13. main()
  14. {
  15.   qp_init();                     /* Initialize qprintf and qputch */
  16.   clrscr();
  17.  
  18.   qprintf(20,13,7,"Demo using cprintf and putch (press a key)");
  19.   getch();
  20.  
  21.   cpdemo();                      /* Do the cprintf and putch demo */
  22.  
  23.   qprintf(20,13,7,"Demo using qprintf and qputch (press a key)");
  24.   getch();
  25.  
  26.   qpdemo();                      /* Do the qprintf and qputch demo */
  27. }
  28.  
  29.  
  30. void qpdemo(void)
  31. {
  32.   int x,y,j,k,m,n;
  33.   char *msg1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  34.   char *msg2 = "abcdefghijklmnopqrstuvwxyz";
  35.   char *msg3 = "0123456789";
  36.  
  37.   /* Print 15 screens in different colors using qprintf*/
  38.  
  39.   for (j = 1; j <= 15; j++)
  40.     for (y = 1; y <= 25; y++)
  41.       qprintf(1,y,j,"Color: %2d - %s %s %s",j,msg1,msg2,msg3);
  42.  
  43.   /* Clear the screen in a roundabout way using qputch */
  44.  
  45.   for (j=80, k=25, m=n=1; j >= m && k >= n; j--, k--, m++, n++)
  46.   {
  47.     for (x = m; x <= j; x++)
  48.       qputch(x,n,7,' ');
  49.     for (y = n; y <= k; y++)
  50.       qputch(m,y,7,' ');
  51.     for (x = j; x >= m; x--)
  52.       qputch(x,k,7,' ');
  53.     for (y = k; y >= n; y--)
  54.       qputch(j,y,7,' ');
  55.   }
  56. }
  57.  
  58. void cpdemo(void)
  59. {
  60.   int x,y,j,k,m,n;
  61.   char *msg1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  62.   char *msg2 = "abcdefghijklmnopqrstuvwxyz";
  63.   char *msg3 = "0123456789";
  64.  
  65.   /* Print 15 screens in different colors using cprintf*/
  66.  
  67.   for (j = 1; j <= 15; j++)
  68.     for (y = 1; y <= 25; y++)
  69.     {
  70.       gotoxy(1,y);
  71.       textattr(j);
  72.       cprintf("Color: %2d - %s %s %s",j,msg1,msg2,msg3);
  73.     }
  74.  
  75.   /* Clear the screen in a roundabout way using putch */
  76.  
  77.   textattr(7);
  78.   for (j=79, k=25, m=n=1; j >= m && k >= n; j--, k--, m++, n++)
  79.   {
  80.     for (x = m; x <= j; x++)
  81.     {
  82.       gotoxy(x,n);
  83.       putch(' ');
  84.     }
  85.     for (y = n; y <= k; y++)
  86.     {
  87.       gotoxy(m,y);
  88.       putch(' ');
  89.     }
  90.     for (x = j; x >= m; x--)
  91.     {
  92.       gotoxy(x,k);
  93.       putch(' ');
  94.     }
  95.     for (y = k; y >= n; y--)
  96.     {
  97.       gotoxy(j,y);
  98.       putch(' ');
  99.     }
  100.   }
  101. }
  102.